package com.net.common.util;

import java.io.IOException;
import java.net.Socket;

public class ValidatorUtils {
    /**
     * 验证本地连接是否可用
     *
     * @param ip   本地ip
     * @param port 端口
     * @return boolean
     */
    public static boolean validate(String ip, int port) {
        Socket socket = null;
        try {
            socket = new Socket(ip, port);
        } catch (IOException e) {
            return false;
        } finally {
            CloseableUtils.close(socket);
        }
        return true;
    }
}
